<form id="form_potentials_showedit" method="post" action="y.php?r=potentials/savedata">
    <input type="hidden" name="potentials_id" value="">
    <table class="tab_form">
        <tr>
            <td><input class="easyui-textbox" name="potentials_name" data-options="label:'销售机会名称:',required:true"></td>
            <td>
                <select id="potentials_customer" class="easyui-combotree" style="width:200px;"
                        data-options="url:'y.php?r=settings/user/loadusertree',required:true,multiple:false,label:'选择用户:'"></select>
                <input type="hidden" name="customer_id">
            </td>
            <td><select class="easyui-combobox" name="stage" data-options="label:'销售阶段:',required:true">
                    <option value="无">
                        无
                    </option>
                    <option value="初期沟通">
                        初期沟通
                    </option>
                    <option value="立项评估">
                        立项评估
                    </option>
                    <option value="需求分析">
                        需求分析
                    </option>
                    <option value="方案指定">
                        方案指定
                    </option>
                    <option value="招投标/竞争">
                        招投标/竞争
                    </option>
                    <option value="商务谈判">
                        商务谈判
                    </option>
                    <option value="谈成结束">
                        谈成结束
                    </option>
                    <option value="未成结束">
                        未成结束
                    </option>
                </select></td>
        </tr>
        <tr>
            <td><select class="easyui-combobox" name="possibility" data-options="label:'成交可能性:',required:true">
                    <option value="25">25%</option>
                    <option value="50">50%</option>
                    <option value="75">75%</option>
                    <option value="100">100%</option>
                </select></td>
            <td><input class="easyui-datebox" name="duedate"
                       data-options="label:'成交日期:',required:true"></td>
            <td><input class="easyui-textbox" name="nextstep" data-options="label:'下一步:',required:true"></td>
        </tr>
    </table>
</form>
<div style="text-align:center;padding:5px 0">
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()" style="width:80px">保存</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()" style="width:80px">清空</a>
</div>
<script>
    var dataobj = <?php echo json_encode($potentials) ?>;
    $(function () {
        $('#form_potentials_showedit').form('load', dataobj);
        if(dataobj!=null){
            $('#potentials_customer').combotree({
                onLoadSuccess:function (node,data) {
                    $('#potentials_customer').combotree("setValue",dataobj.customer_id)
                }
            });
//            $('#potentials_customer').combotree("setValue",dataobj.customer_id)
        }
    });
    function submitForm() {
        $("input[name=customer_id]").val($('#potentials_customer').combotree("getValue"));
        $('#form_potentials_showedit').form('submit', {
            success: function () {
                $('#win_main').window("close");
                $("#potentials_list").datagrid("reload");
            }
        });
    }
    function clearForm() {
        $('#form_potentials_showedit').form('clear');
        $('#potentials_customer').combotree("clear")
        if (dataobj != null) {
            $("input[name=potentials_id]").val(dataobj.potentials_id);
        }
    }
</script>